package com.wcll.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.wcll.*;
import com.wcll.bean.CQM_JianLi;

public class CQM_ZhuCeServlet extends HttpServlet {

	/**
	 * Constructor of the object.
	 */
	public CQM_ZhuCeServlet() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		CQM_JianLi jianli = new CQM_JianLi();
		response.setContentType("text/html; charset=UTF-8");
		request.setCharacterEncoding("UTF-8");

		try {

			String name = request.getParameter("name");
			String pass = request.getParameter("pass");
			String email = request.getParameter("email");
			jianli.setName(name);
			jianli.setPass(pass);
			jianli.setEmail(email);
			request.getSession().setAttribute("user",
					request.getParameter("name"));
			boolean f = jianli.zhuCe1(jianli);

			if (f) {

				this.getServletContext().getRequestDispatcher("/cqm_zhuCe.jsp")
						.forward(request, response);
			} else {
				this.getServletContext().getRequestDispatcher("/index.jsp")
						.forward(request, response);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	public void init() throws ServletException {
		// Put your code here
	}

}
